package com.roobtyan.todomemback.controller;

import com.roobtyan.todomemback.entity.CardDir1;
import com.roobtyan.todomemback.service.CardDirService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;

@Controller
@RequestMapping("/dir")
@CrossOrigin
public class CardDirController {
    @Resource
    private CardDirService cardDirService;

    @GetMapping("/getAllDir1")
    @ResponseBody
    public Object getAllDir1() {
        return cardDirService.getAllDir1();
    }

    @GetMapping("/addDir1")
    @ResponseBody
    public void addDir1(CardDir1 cardDir1) {
        cardDir1.setCreateTime(new Date());
        cardDirService.insertDir1(cardDir1);
    }

    @GetMapping("/updateDir1")
    @ResponseBody
    public void updateDir1(CardDir1 cardDir1) {
        cardDirService.updateDir1(cardDir1);
    }

    @GetMapping("/deleteDir1")
    @ResponseBody
    public void deleteDir1(int dir1Id) {
        cardDirService.deleteDir1(dir1Id);
    }
}
